package com.citywithincity.db.drivers.mysql;

public class MysqlSqlHelper {
	
	

	/**
	 * 修改表注释的语句
	 * @param tableName
	 * @param comment
	 * @return
	 */
	public static String alterTableComment(String tableName, String comment){
		return String.format("ALTER TABLE `%s` COMMENT '%s';",tableName,comment);
	}

	/**
	 * 修改字段注释
	 * @param tableName
	 * @param column
	 * @param comment
	 * @return
	 */
	public static String alertColumnComment(String tableName, String column, String comment){
		return String.format("ALTER TABLE `%s` MODIFY COLUMN `%s` COMMENT '%s';",tableName,column,comment);
	}
	
	/**
	 * 修改表名称
	 * @param tableName
	 * @param newName
	 * @return
	 */
	public static String alterTableName(String tableName,String newName){
		return String.format("rename table %s to %s;", tableName,newName);
	}
	
	/**
	 * 全部表名称
	 * @param db
	 * @return
	 */
	public static String allTableNames(String db){
		return String.format("select distinct(table_name) as table_name from information_schema.columns where table_schema='%s'", db);
	}
	
	
}
